#include <iostream>
#include <unordered_map>

using namespace std;
std::unordered_map<int, int> mp;
int n, m;
bool check(int x){
    int g = 0;
    for (auto& p : mp){
        if (p.second < x) g++;
        else g += p.second / x, g += (p.second % x ? 1 : 0);
    }
//     恰好分成m组也包含小于的情况！
    return g <= m;
}
int main(){
//     ok 现在我们知道这个算法的作用了，二分加枚举！
    cin >> n >> m;
    int hmx = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        hmx = max(++mp[x], hmx);
    }
    if (mp.size() > m) {
        cout << -1 << endl;
        return 0;
    }
//     接下来开始枚举区间内的数字，找到答案
    int left = 1, right = hmx;
    while (left < right){
        int mid = (right + left ) / 2;
        if (check(mid)) right = mid;
        else left = mid + 1;
    }
    cout << left << endl;
    return 0;
}